import { setInterval } from "timers";
import * as vscode from "vscode";
import { showErrorMessage } from "./message";

export function activate(context: vscode.ExtensionContext) {
  let disposable = vscode.commands.registerCommand(
    "2-plugin.helloWorld",
    async () => {
      // vscode.window.showInformationMessage('helloWorld');
      // vscode.window.showWarningMessage("helloWorld");
      // showErrorMessage();
    //  const result = await vscode.window.showInputBox({
    //    value: "abcdef",
		// 	 password:false,

    //    valueSelection: [2, 4],
    //    placeHolder: "For example: fedcba. But not: 123",
    //    validateInput: (text) => {
    //      return text === "123" ? "Not 123!" : null;
    //    },
    //  });
		//  var result = await vscode.window.showOpenDialog({
    //    title: "你好",
    //    openLabel: "确定",
    //    defaultUri:vscode.Uri.file('/')
    //  });
		//  console.log(result)
		//  var channel = vscode.window.createOutputChannel('你好')
		// 	channel.show();
		// 	setInterval(()=>{
		// 		channel.appendLine("124");
        
		// 	},1000)
		
		window.withProgress(
      {
        location: ProgressLocation.Notification,
        title: "I am long running!",
        cancellable: true,
      },
      (progress, token) => {
        token.onCancellationRequested(() => {
          console.log("User canceled the long running operation");
        });

        progress.report({ increment: 0 });

        setTimeout(() => {
          progress.report({
            increment: 10,
            message: "I am long running! - still going...",
          });
        }, 1000);

        setTimeout(() => {
          progress.report({
            increment: 40,
            message: "I am long running! - still going even more...",
          });
        }, 2000);

        setTimeout(() => {
          progress.report({
            increment: 50,
            message: "I am long running! - almost there...",
          });
        }, 3000);

        const p = new Promise<void>((resolve) => {
          setTimeout(() => {
            resolve();
          }, 5000);
        });

        return p;
      }
    );

      // vscode.window.showInformationMessage(`Got: ${result}`);
    }
  );

  context.subscriptions.push(disposable);
}

// this method is called when your extension is deactivated
export function deactivate() {}
